<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%depot_position}}".
 *
 * @property integer $id
 * @property string $sn
 * @property integer $depot_id
 * @property integer $created_at
 *
 * @property Depot $depot
 */
class DepotPosition extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%depot_position}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['sn', 'depot_id'], 'required'],
            [['depot_id'], 'integer'],
            [['sn'], 'string', 'max' => 255],
           
            [['depot_id'], 'exist', 'skipOnError' => true, 'targetClass' => Depot::className(), 'targetAttribute' => ['depot_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'sn' => '编号',
            'depot_id' => 'Depot ID',
            'created_at' => 'Created At',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getDepot()
    {
        return $this->hasOne(Depot::className(), ['id' => 'depot_id']);
    }
}
